<!DOCTYPE html>
<title>Test that a "source" element is not used when a bogus "src" attribute is present.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<video>
    <source></source>
</video>
<script>
async_test(function(t) {
    var video = document.querySelector("video");

    video.onloadedmetadata = t.unreached_func();
    video.onloadstart = t.step_func(function () {
        var url = video.currentSrc;
        assert_equals(url.substr(url.lastIndexOf("/media/")+7), mediaFile);
    });

    video.onerror = t.step_func(function () {
        var url = video.currentSrc;
        assert_equals(url.substr(url.lastIndexOf("/media/")+7), mediaFile);
        assert_equals(video.error.code, MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED);
        setTimeout(t.step_func_done(), 200) ;
    });

    document.querySelector("source").src = "content/test.ogv";
    var mediaFile = "content/bogus.mpeg";
    video.src = mediaFile;
});
</script>